import { createApp } from 'vue'
import App from './App.vue'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import DefaultRouter from '@/route/DefaultRouter'
import DBInitScript from '@/config/DBInitScript'
import ServletUtils from "@/utils/ServletUtils";

// data base dir
const fs = require('fs')
const appDataDir = ServletUtils.get("appDir")
const myAppDataDir = `${appDataDir}/ssl-tools`
if (!fs.existsSync(myAppDataDir)) {
    fs.mkdirSync(myAppDataDir)
}
const dbFile = `${myAppDataDir}/data.db`

const mainApp = createApp(App)

mainApp.use(ElementPlus, {
    size: 'small',
    zIndex: 3000,
    fontSize: 12
})

mainApp.config.globalProperties.$router = DefaultRouter
mainApp.config.globalProperties.$store = {
    db: dbFile,
    initScripts: DBInitScript.scripts
}

mainApp.mount('#app')
